﻿$(function () {
    $('#LGAsDivID').hide();
    $('#SubmitID').hide();

    $('#StateID').change(function () {
        var URL = $('#CreateLGAForm').data('LGAListAction');
        $.getJSON(URL + '/' + $('#StatesID').val(),
            function (data) {
                var items = '<option>Select a LGA</option>';
                $.each(data, function (i, LGA) {
                    items += "<option value='" + LGA.Value + "'>" + LGA.Text + "</option>";
                    // LGA.Value cannot contain ' character. We are OK because LGA.Value = cnt++;
                });
                $('#LGAsID').html(items);
                $('#LGAsDivID').show();
            });
    });
});